package com.hzlx.web;

import com.hzlx.dto.CourseDto;
import com.hzlx.dto.CourseRequestDto;
import com.hzlx.dto.PageDto;
import com.hzlx.dto.ResultDto;
import com.hzlx.service.CourseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class CourseController {
   private final CourseService courseService;
   @PostMapping("/courses")
   public ResultDto<PageDto<CourseDto>> loadCourseByJson(@RequestBody CourseRequestDto course){
      //...
      return courseService.loadCourseByPage(course.getAccount(),course.getPage(),course.getRows());
   }
   @PostMapping("/coursesForm")
   public ResultDto<PageDto<CourseDto>> loadCourseByForm(CourseRequestDto course){
      //...
      return courseService.loadCourseByPage(course.getAccount(),course.getPage(),course.getRows());
   }
   @GetMapping("/courses/{account}/{page}/{rows}")
   public ResultDto<PageDto<CourseDto>> queryCourses(@PathVariable("account") String account,
                                                      @PathVariable("rows") Integer rows,
                                                      @PathVariable("page") Integer page)
   {
      //...
      return courseService.loadCourseByPage(account,page,rows);
   }
}